package com.itheima.d6_object_stream;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

/*
  目标：掌握对象字节输出流的使用：序列化对象。
 */
public class Test1ObjectOutputStream {
    public static void main(String[] args) throws Exception {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("ss.txt"));
        Student zs = new Student("zhangsan", 20);
        Student ls = new Student("lisi", 10);
        Student ww = new Student("wangwu", 25);
        Student dd = new Student("dahai", 22);
        ArrayList<Student> stu = new ArrayList<>();
        stu.add(zs);
        stu.add(ls);
        stu.add(ww);
        stu.add(dd);
        oos.writeObject(stu);
        oos.close();
    }
}
